package com.changgou.fastdfs;

import org.csource.common.MyException;
import org.csource.fastdfs.ClientGlobal;
import org.csource.fastdfs.StorageClient;
import org.csource.fastdfs.TrackerClient;
import org.csource.fastdfs.TrackerServer;

import java.io.IOException;

/**
 * @author 1
 * @data 2022/1/9
 */
public class StorageClientUtils {

    public StorageClient CreateStorageClient(){
        TrackerServer trackerServer = null;
        try {
            //创建一个配置文件 填写服务端ip端口
            //加载配置文件建立连接
            ClientGlobal.init("D:\\Java\\javaEE\\changgou\\changgou-parent\\changgou-service\\changgou-service-file\\src\\main\\resources\\fdfs_client.conf");

            //创建trackerClient
            TrackerClient trackerClient = new TrackerClient();
            //根据trackerClient获取连接对象
            trackerServer = trackerClient.getConnection();
        } catch (Exception e) {
            e.printStackTrace();
        }
        //创建storageServer 对象设置null
        //创建storageClient 提供了很多的操作图片的Api
        StorageClient storageClient = new StorageClient(trackerServer, null);

        return storageClient;
    }


}
